<?php
namespace app\admin\controller;

use app\BaseController;
use think\facade\Db;

class Flink extends Base
{
    public function index()
    {
        $flinkData = Db::name('flink')->paginate(10);
        return view('', [
            'flinkData' => $flinkData
        ]);
    }

    public function add()
    {
        if (request()->isPost()) {
            $data = input('post.');
            $res  = Db::name('flink')->insert($data);
            if ($res) {
                return alert("操作成功",'index', 6);
            }

            return alert("操作失败",'index', 5);
        }

        return view();
    }

    public function edit()
    {
        $id = input('id');
        $flinkData = Db::name('flink')->find($id);

        return view('', [
            'flinkData' => $flinkData
        ]);
    }

    public function update()
    {
        $data = input('post.');
        $res  = Db::name('flink')->update($data);
        if ($res) {
            return alert("操作成功",'index', 6);
        }

        return alert("操作失败",'index', 5);
    }

    public function del()
    {
        $id = input('id');
        $res  = Db::name('flink')->delete($id);
        if ($res) {
            return alert("操作成功",'index', 6);
        }

        return alert("操作失败",'index', 5);
    }
}